package com.jin.lazytool.entity;

import javafx.scene.control.Label;
import javafx.scene.control.TextField;
import javafx.scene.layout.FlowPane;
import javafx.scene.layout.Pane;
import javafx.scene.paint.Color;

import java.awt.event.KeyEvent;

public abstract class KeyDownUpEvent extends IEvent{
    private int keyCode;

    public KeyDownUpEvent() {
    }


    public KeyDownUpEvent(KeyEvent keyEvent) {
        this.keyCode = keyEvent.getKeyCode();
    }

    public KeyDownUpEvent(KeyEvent keyEvent, Integer time) {
        this.keyCode = keyEvent.getKeyCode();
        setTime(time);
    }



    @Override
    public Pane initDesc() {
        FlowPane pane = new FlowPane();
        pane.setStyle("-fx-pref-height: 26;");
        Label label = new Label(initDescVal());
        label.setTextFill(Color.GRAY);
        TextField field = new TextField(KeyEvent.getKeyText(keyCode));
        field.setEditable(false);
        pane.getChildren().addAll(label, field);
        return pane;
    }

    abstract String initDescVal();

    @Override
    public void show() {

    }

    public int getKeyCode() {
        return keyCode;
    }

    public void setKeyCode(int keyCode) {

        this.keyCode = keyCode;
    }
}
